#include <cstdio>
typedef long long ll;
int n, m, tot;
ll ans;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("pol.in", "r", stdin);
  freopen("pol.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  ++n, ++m;
  tot = n * m;
  ans = 1ll * tot * (tot - 1) * (tot - 2) / 6 - 1ll * n * m * (m - 1) * (m - 2) / 6 -
        1ll * m * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      ans -= 2ll * (gcd(i, j) - 1) * (n - i) * (m - j);
    }
  }
  printf("%lld", ans);
  return 0;
}